// pages/material/list.js
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    materialList: [],
    roomGuid : ""

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {   
    var that = this;
    this.setData({
      roomGuid: options.roomGuid
    });    
  },
  onShow:function(){
    this.loadMaterialList(this.data.roomGuid);
  },

  // 加载资料列表
  loadMaterialList: function(roomid) {
    var phone = wx.getStorageSync(app.cacheKey.userInfo_phone);
    var that = this;
    var url = app.getUrl('GetCustomerDataList');
    var header = app.getRequestHeader();
    wx.request({
      url: url,
      method: 'POST',
      data:{
        roomGuid: roomid,
        tel: phone
      }, /*"'" + roomid + "'",//BDB6CBCE-C149-E811-93EB-7427EA1A399B*/
      header: header,
      success: function(res) {
        console.log(res);
        if (res.data.success) {
          var dataList = res.data.data;
          var newDataList = [];
          for (var i = 0; i < dataList.length; i++) {
            var data = dataList[i];
            var page = "";
            if (1 == data.AuditStatusEnum || 3 == data.AuditStatusEnum) {
              page = "detail";
            } else if ("身份证" == data.DataTypeName) {
              page = "idcard";
            } else if (data.DataTypeName.indexOf("户口本") > -1) {
              page = "household";
            }
            var url = page + "?type =" + data.DataTypeGUID + "&typename=" + data.DataTypeName + "&cstguid=" + data.CstGuid + "&auditStatus=" + data.AuditStatus;
            data["url"] = url;
          }
          that.setData({
            materialList: dataList
          })
        }
      }
    })
  }
})